#!/usr/bin/env python

#40*x^3 + 600x - 3y = 0
#x=?

import struct

AGENT = 'new char'
AGENCY = 'Black Rose'
CREDITS = 298280
MISSIONS = struct.pack( 'h', 31337 )
VICTORIES = struct.pack( 'h', 31337 )
FORFEITS = struct.pack( 'h', 0 )

AGENT += chr( 0 ) * ( 20 - len( AGENT ) )

AGENCY=chr({'Noxis':0,'Lazarus':1,'Caliber':2,'Static':3,'Black Rose':4}[AGENCY])

LEVEL = ADVANTS = ENDURANCE = SHIELD = JETPACK = HACKING = CONTACTS = chr( 0 )
TECHSLOTS = chr( 6 )
if CREDITS > 209:
	LEVEL=chr(1)
	CONTACTS=chr(1)
	TECHSLOTS=chr(6)
if CREDITS>499:
	LEVEL=chr(2)
	HACKING=chr(1)
	CONTACTS=chr(1)
	TECHSLOTS=chr(6)
if CREDITS>959:
	LEVEL=chr(3)
	HACKING=chr(2)
	CONTACTS=chr(1)
	TECHSLOTS=chr(6)
if CREDITS>1649:
	LEVEL=chr(4)
	HACKING=chr(3)
	CONTACTS=chr(1)
	TECHSLOTS=chr(6)
if CREDITS>2659:
	LEVEL=chr(5)
	HACKING=chr(4)
	CONTACTS=chr(1)
	TECHSLOTS=chr(6)
if CREDITS>4079:
	LEVEL=chr(6)
	HACKING=chr(5)
	CONTACTS=chr(1)
	TECHSLOTS=chr(6)
if CREDITS>5969:
	LEVEL=chr(7)
	HACKING=chr(5)
	CONTACTS=chr(2)
	TECHSLOTS=chr(6)
if CREDITS>8419:
	LEVEL=chr(8)
	HACKING=chr(5)
	CONTACTS=chr(3)
	TECHSLOTS=chr(6)
if CREDITS>11519:
	LEVEL=chr(9)
	HACKING=chr(5)
	CONTACTS=chr(4)
	TECHSLOTS=chr(6)
if CREDITS>15329:
	LEVEL=chr(10)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>19939:
	LEVEL=chr(11)
	JETPACK=chr(1)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>25439:
	LEVEL=chr(12)
	JETPACK=chr(2)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>31879:
	LEVEL=chr(13)
	JETPACK=chr(3)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>39379:
	LEVEL=chr(14)
	JETPACK=chr(4)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>47999:
	LEVEL=chr(15)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>57799:
	LEVEL=chr(16)
	ENDURANCE=chr(1)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>68899:
	LEVEL=chr(17)
	ENDURANCE=chr(2)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>81359:
	LEVEL=chr(18)
	ENDURANCE=chr(3)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>95239:
	LEVEL=chr(19)
	ENDURANCE=chr(4)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>110659:
	LEVEL=chr(20)
	ENDURANCE=chr(5)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>127679:
	LEVEL=chr(21)
	ENDURANCE=chr(5)
	SHIELD=chr(1)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>146359:
	LEVEL=chr(22)
	ENDURANCE=chr(5)
	SHIELD=chr(2)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>166809:
	LEVEL=chr(23)
	ENDURANCE=chr(5)
	SHIELD=chr(3)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>189119:
	LEVEL=chr(24)
	ENDURANCE=chr(5)
	SHIELD=chr(4)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>213319:
	LEVEL=chr(25)
	ENDURANCE=chr(5)
	SHIELD=chr(5)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(6)
if CREDITS>239529:
	LEVEL=chr(26)
	ENDURANCE=chr(5)
	SHIELD=chr(5)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(7)
if CREDITS>267839:
	LEVEL=chr(27)
	ENDURANCE=chr(5)
	SHIELD=chr(5)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(8)
if CREDITS>298279:
	LEVEL=chr(28)
	ADVANTS=chr(1)
	ENDURANCE=chr(5)
	SHIELD=chr(5)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(8)
if CREDITS>330969:
	LEVEL=chr(29)
	ADVANTS=chr(1)
	ENDURANCE=chr(5)
	SHIELD=chr(5)
	JETPACK=chr(5)
	HACKING=chr(5)
	CONTACTS=chr(5)
	TECHSLOTS=chr(8)

CREDITS = struct.pack( 'i', CREDITS )

PLAYERS_DAT = open( 'PLAYERS.DAT' ).read()

NUM_PLAYERS = ord( PLAYERS_DAT[0] )

PLAYERS_DAT=(
PLAYERS_DAT[16:].decode('zlib_codec')[:struct.unpack('h',PLAYERS_DAT[8:10])[0]*NUM_PLAYERS]
+AGENT+'\x00'*21+AGENCY+ADVANTS+ENDURANCE+SHIELD+JETPACK+HACKING+CONTACTS+'\x00'*3
+TECHSLOTS+'\x00'*9+LEVEL+'\x00'*4+FORFEITS+VICTORIES+MISSIONS+'\x00'*4+CREDITS+'\x00'*93).encode('zlib_codec')

x = open('PLAYERS.DAT','wb')
x.write(chr(NUM_PLAYERS+1)+'\x00'*3+'\x06'+'\x00'*3+'\xAC'+'\x00'*3+struct.pack('h',len(PLAYERS_DAT))+'\x00'*2
+PLAYERS_DAT)
x.close()
